package com.jj.conterllor;


import com.jj.entity.menu;
import com.jj.service.MenuService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;



@Controller
@RequestMapping("/m")
public class menuconterllor {

    @Resource
    private MenuService menuService;

    //查询全表
    @RequestMapping("menu")
    public String selectaAll(Model modle){
        List<menu> m = menuService.selectaAll();
        modle.addAttribute("menus",m);
        return "muselect";
    }

    //添加数据
    @RequestMapping("add")
    public String d(){
        return "muinsert";
    }
    @RequestMapping("muinsert")
    public String addtj(menu m){
        menuService.insertadd(m);
        return "forward:menu";
    }

    //删除数据fdfd
    @RequestMapping("/shan")
    public String shanchu(int menu_id){
        menuService.deleteshan(menu_id);
        return "forward:menu";
    }

    //修改数据
    @RequestMapping("xiugai")
    public String x(Model modle, int menu_id){
        modle.addAttribute("mid",menu_id);
        return "muupdate";
    }
    @RequestMapping("/muupdate")
    public String xiugai(menu m){

        menu mu = new menu();

        mu.setMenuList(m.getMenuList());
        mu.setMenu_name(m.getMenu_name());

        menuService.updatexiu(mu);
        return "forward:menu";
    }
}


